'use strict';
app
		.controller(
				'MenuCtrl',
				[
						'$scope',
						'$modal',
						'$rootScope',
						'$state',
						'$stateParams',
						'$filter',
						'$interval',
						'toaster',
						'commonService','userService',
						function($scope, $modal, $rootScope, $state, $stateParams, $filter,$interval,
								toaster, commonService,userService) {
							$scope.Menus = [];
							getMenus();

							$scope.isMShow = function(id){

								if(userService.IsAdmin()){
									return true;
								}else{
									var obj = $scope.Menus;
									for(var i=0;i<obj.length;i++){
										if(id == obj[i]['moduleNo'] || id == obj[i]['pageNo']){
											return true;
										}
									}
									return false;
								}

							};

							function getMenus() {
								if(userService.IsAdmin())
									return true;

								commonService.httpJson("userFunction/sall", { roleId: userService.getRoleId()})
									.success( function(data, status) {
										if (data && data['code'] == 0) {
											$scope.Menus = data['data'];
										} else {
											commonService.toasterError(data['message']);
										}
									});
							}

						} ]);